package com.ceair.flight.refund.dto.ota;


import java.util.Arrays;
import java.util.List;

import com.ceair.muservice.common.dto.BaseReq;

/**
 * 可以机票与保险一起退和单独退机票, 不可以单独退保险
 */
public class RefundReq extends BaseReq {

	private String orderNo;
	private String appName;
	private String appContact;
	/*
	 * 登录用户passportId
	 **/
	private Long passportId;
	/*
	 * 订单所属用户passportId
	 **/
	private Long orderPassportId;
	/**
	 * 281：自愿退票 282：非自愿退票(其他,拒签或者系统问题等) 283：航班延误或取消(航空公司原因) 286：病退 287：另购客票
	 */
	private long applyType;
	private String reason;
	/**
	 * 要退的成人乘机人id，多个以逗号分隔，形式为：paxId1,paxId2...
	 */
	private String paxIdsAdt;

	/**
	 * 要退保险的成人乘机人id，多个以逗号分隔，形式为：paxId1,paxId2...
	 */
	private String insurePaxIdsAdt;
	/**
	 * 要退的儿童乘机人id，多个以逗号分隔，形式为：paxId1,paxId2...
	 */
	private String paxIdsChd;
	/**
	 * 要退保险的儿童乘机人id，多个以逗号分隔，形式为：paxId1,paxId2...
	 */
	private String insurePaxIdsChd;
	/**
	 * 要退的婴儿乘机人id，多个以逗号分隔，形式为：paxId1,paxId2...
	 */
	private String paxIdsInf;
	/**
	 * 要退保险的婴儿乘机人id，多个以逗号分隔，形式为：paxId1,paxId2...
	 */
	private String insurePaxIdsInf;

	private String channelUserKey;

	private List<RefundAttachment> attachments;

	private String repurchaseTicket;

	public String getRepurchaseTicket() {
		return repurchaseTicket;
	}

	public void setRepurchaseTicket(String repurchaseTicket) {
		this.repurchaseTicket = repurchaseTicket;
	}

	public List<RefundAttachment> getAttachments() {
		return attachments;
	}

	public void setAttachments(List<RefundAttachment> attachments) {
		this.attachments = attachments;
	}

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public String getAppName() {
		return appName;
	}

	public void setAppName(String appName) {
		this.appName = appName;
	}

	public String getAppContact() {
		return appContact;
	}

	public void setAppContact(String appContact) {
		this.appContact = appContact;
	}

	public Long getOrderPassportId() {
		return orderPassportId;
	}

	public void setOrderPassportId(Long orderPassportId) {
		this.orderPassportId = orderPassportId;
	}

	public long getApplyType() {
		return applyType;
	}

	public void setApplyType(long applyType) {
		this.applyType = applyType;
	}

	public String getReason() {
		return reason;
	}

	public void setReason(String reason) {
		this.reason = reason;
	}

	public String getPaxIdsAdt() {
		return paxIdsAdt;
	}

	public void setPaxIdsAdt(String paxIdsAdt) {
		this.paxIdsAdt = paxIdsAdt;
	}

	public String getPaxIdsChd() {
		return paxIdsChd;
	}

	public void setPaxIdsChd(String paxIdsChd) {
		this.paxIdsChd = paxIdsChd;
	}

	public String getPaxIdsInf() {
		return paxIdsInf;
	}

	public void setPaxIdsInf(String paxIdsInf) {
		this.paxIdsInf = paxIdsInf;
	}

	public Long getPassportId() {
		return passportId;
	}

	public void setPassportId(Long passportId) {
		this.passportId = passportId;
	}

	public String getChannelUserKey() {
		return channelUserKey;
	}

	public void setChannelUserKey(String channelUserKey) {
		this.channelUserKey = channelUserKey;
	}

	public String getInsurePaxIdsAdt() {
		return insurePaxIdsAdt;
	}

	public void setInsurePaxIdsAdt(String insurePaxIdsAdt) {
		this.insurePaxIdsAdt = insurePaxIdsAdt;
	}

	public String getInsurePaxIdsChd() {
		return insurePaxIdsChd;
	}

	public void setInsurePaxIdsChd(String insurePaxIdsChd) {
		this.insurePaxIdsChd = insurePaxIdsChd;
	}

	public String getInsurePaxIdsInf() {
		return insurePaxIdsInf;
	}

	public void setInsurePaxIdsInf(String insurePaxIdsInf) {
		this.insurePaxIdsInf = insurePaxIdsInf;
	}

	private static final long FILESIZE = 200 * 1024;
	// 退票接口支持的退票类型
	public static final List<Long> APPLY_TYPES = Arrays.asList(281l, 282l, 283l,
			/* 284l,285l, */286l, 287l);

	public String checkParameter() {
		if (!APPLY_TYPES.contains(getApplyType())) {
			return "退票类型不正确";
		}
		if (attachments != null && attachments.size() > 0) {
			if (attachments.size() > 16) {
				return "最多只能上传16个附件";
			}
			for (RefundAttachment ra : attachments) {
				if (null == ra.getContent() || 0 == ra.getContent().length || null == ra.getName()
						|| "".equals(ra.getName())) {
					return "附件文件名或者内容不能为空";
				}
				if (ra.getContent().length > FILESIZE) {
					return "每个附件大小不能超过200KB";
				}
			}
		}
		return null;
	}
}
